/*
 * BanBu_NewVersionViewController
 * @description 本文件提供新版本介绍界面的ViewController
 * @package
 * @author 		***
 * @copyright
 * @version 		1.0
 * @description 本文件提供新版本介绍界面的ViewController
 */


#import "BanBu_NewVersionViewController.h"
#import "BanBu_NavButton.h"
#import "AppDataManager.h"
@interface BanBu_NewVersionViewController ()

@end

@implementation BanBu_NewVersionViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        // Custom initialization
    }
    return self;
}
-(void)popself
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, __MainScreen_Width, __MainScreen_Height-44)];
    
    NSURLRequest *request = nil;
    if([[MyAppDataManager getPreferredLanguage] isEqualToString:@"zh-Hans"])
    {
        
        request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.koochat.com/apphelp/vernew_cn.html"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
    }
    else if([[MyAppDataManager getPreferredLanguage] isEqualToString:@"ja"])
    {
        request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.koochat.com/apphelp/vernew_jp.html"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
    }
    else
    {
        request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.koochat.com/apphelp/vernew_en.html"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0];

    }
    [_webView loadRequest:request];

//    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.koochat.com/vernew.html"]]];
    _webView.delegate = self;

    [self.view addSubview:_webView];
    [_webView release];
    self.title  = NSLocalizedString(@"newVersionIntroduce", nil);
    [TKLoadingView showTkloadingAddedTo:self.view title:NSLocalizedString(@"loadingNotice", nil) activityAnimated:YES];

}
-(void)viewWillAppear:(BOOL)animated
{
    [UIView setAnimationsEnabled:YES];
    [super viewWillAppear:animated];
}
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
        NSURL *requestURL =[ [ request URL ] retain ];
        if(navigationType == UIWebViewNavigationTypeLinkClicked){
            if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ])) {
                return ![ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];
            }
        }
        [ requestURL release ];
        return YES;    
}
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    [TKLoadingView dismissTkFromView:self.view animated:NO afterShow:0];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

@end
